
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pymatgen.core.periodic_table &#8212; pymatgen 2020.7.3 documentation</title>
    <link rel="stylesheet" href="../../../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../../" src="../../../_static/documentation_options.js"></script>
    <script src="../../../_static/jquery.js"></script>
    <script src="../../../_static/underscore.js"></script>
    <script src="../../../_static/doctools.js"></script>
    <script src="../../../_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.core.periodic_table</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.core.periodic_table</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) Pymatgen Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License.</span>

<span class="sd">&quot;&quot;&quot;Module contains classes presenting Element and Specie (Element + oxidation state) and PeriodicTable.&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">json</span>
<span class="kn">import</span> <span class="nn">warnings</span>
<span class="kn">from</span> <span class="nn">io</span> <span class="kn">import</span> <span class="nb">open</span>
<span class="kn">from</span> <span class="nn">pathlib</span> <span class="kn">import</span> <span class="n">Path</span>
<span class="kn">from</span> <span class="nn">enum</span> <span class="kn">import</span> <span class="n">Enum</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Optional</span><span class="p">,</span> <span class="n">Callable</span>
<span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">product</span><span class="p">,</span> \
    <span class="n">combinations</span>
<span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">Counter</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>

<span class="kn">from</span> <span class="nn">pymatgen.core.units</span> <span class="kn">import</span> <span class="n">Mass</span><span class="p">,</span> <span class="n">Length</span><span class="p">,</span> <span class="n">FloatWithUnit</span><span class="p">,</span> <span class="n">Unit</span><span class="p">,</span> \
    <span class="n">SUPPORTED_UNIT_NAMES</span>
<span class="kn">from</span> <span class="nn">pymatgen.util.string</span> <span class="kn">import</span> <span class="n">formula_double_format</span>
<span class="kn">from</span> <span class="nn">monty.json</span> <span class="kn">import</span> <span class="n">MSONable</span>

<span class="c1"># Loads element data from json file</span>
<span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">Path</span><span class="p">(</span><span class="vm">__file__</span><span class="p">)</span><span class="o">.</span><span class="n">absolute</span><span class="p">()</span><span class="o">.</span><span class="n">parent</span> <span class="o">/</span> <span class="s2">&quot;periodic_table.json&quot;</span><span class="p">),</span> <span class="s2">&quot;rt&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
    <span class="n">_pt_data</span> <span class="o">=</span> <span class="n">json</span><span class="o">.</span><span class="n">load</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>

<span class="n">_pt_row_sizes</span> <span class="o">=</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">8</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">32</span><span class="p">,</span> <span class="mi">32</span><span class="p">)</span>


<div class="viewcode-block" id="Element"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Element">[docs]</a><span class="k">class</span> <span class="nc">Element</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;Enum representing an element in the periodic table.&quot;&quot;&quot;</span>

    <span class="c1"># This name = value convention is redundant and dumb, but unfortunately is</span>
    <span class="c1"># necessary to preserve backwards compatibility with a time when Element is</span>
    <span class="c1"># a regular object that is constructed with Element(symbol).</span>
    <span class="n">H</span> <span class="o">=</span> <span class="s2">&quot;H&quot;</span>
    <span class="n">He</span> <span class="o">=</span> <span class="s2">&quot;He&quot;</span>
    <span class="n">Li</span> <span class="o">=</span> <span class="s2">&quot;Li&quot;</span>
    <span class="n">Be</span> <span class="o">=</span> <span class="s2">&quot;Be&quot;</span>
    <span class="n">B</span> <span class="o">=</span> <span class="s2">&quot;B&quot;</span>
    <span class="n">C</span> <span class="o">=</span> <span class="s2">&quot;C&quot;</span>
    <span class="n">N</span> <span class="o">=</span> <span class="s2">&quot;N&quot;</span>
    <span class="n">O</span> <span class="o">=</span> <span class="s2">&quot;O&quot;</span>
    <span class="n">F</span> <span class="o">=</span> <span class="s2">&quot;F&quot;</span>
    <span class="n">Ne</span> <span class="o">=</span> <span class="s2">&quot;Ne&quot;</span>
    <span class="n">Na</span> <span class="o">=</span> <span class="s2">&quot;Na&quot;</span>
    <span class="n">Mg</span> <span class="o">=</span> <span class="s2">&quot;Mg&quot;</span>
    <span class="n">Al</span> <span class="o">=</span> <span class="s2">&quot;Al&quot;</span>
    <span class="n">Si</span> <span class="o">=</span> <span class="s2">&quot;Si&quot;</span>
    <span class="n">P</span> <span class="o">=</span> <span class="s2">&quot;P&quot;</span>
    <span class="n">S</span> <span class="o">=</span> <span class="s2">&quot;S&quot;</span>
    <span class="n">Cl</span> <span class="o">=</span> <span class="s2">&quot;Cl&quot;</span>
    <span class="n">Ar</span> <span class="o">=</span> <span class="s2">&quot;Ar&quot;</span>
    <span class="n">K</span> <span class="o">=</span> <span class="s2">&quot;K&quot;</span>
    <span class="n">Ca</span> <span class="o">=</span> <span class="s2">&quot;Ca&quot;</span>
    <span class="n">Sc</span> <span class="o">=</span> <span class="s2">&quot;Sc&quot;</span>
    <span class="n">Ti</span> <span class="o">=</span> <span class="s2">&quot;Ti&quot;</span>
    <span class="n">V</span> <span class="o">=</span> <span class="s2">&quot;V&quot;</span>
    <span class="n">Cr</span> <span class="o">=</span> <span class="s2">&quot;Cr&quot;</span>
    <span class="n">Mn</span> <span class="o">=</span> <span class="s2">&quot;Mn&quot;</span>
    <span class="n">Fe</span> <span class="o">=</span> <span class="s2">&quot;Fe&quot;</span>
    <span class="n">Co</span> <span class="o">=</span> <span class="s2">&quot;Co&quot;</span>
    <span class="n">Ni</span> <span class="o">=</span> <span class="s2">&quot;Ni&quot;</span>
    <span class="n">Cu</span> <span class="o">=</span> <span class="s2">&quot;Cu&quot;</span>
    <span class="n">Zn</span> <span class="o">=</span> <span class="s2">&quot;Zn&quot;</span>
    <span class="n">Ga</span> <span class="o">=</span> <span class="s2">&quot;Ga&quot;</span>
    <span class="n">Ge</span> <span class="o">=</span> <span class="s2">&quot;Ge&quot;</span>
    <span class="n">As</span> <span class="o">=</span> <span class="s2">&quot;As&quot;</span>
    <span class="n">Se</span> <span class="o">=</span> <span class="s2">&quot;Se&quot;</span>
    <span class="n">Br</span> <span class="o">=</span> <span class="s2">&quot;Br&quot;</span>
    <span class="n">Kr</span> <span class="o">=</span> <span class="s2">&quot;Kr&quot;</span>
    <span class="n">Rb</span> <span class="o">=</span> <span class="s2">&quot;Rb&quot;</span>
    <span class="n">Sr</span> <span class="o">=</span> <span class="s2">&quot;Sr&quot;</span>
    <span class="n">Y</span> <span class="o">=</span> <span class="s2">&quot;Y&quot;</span>
    <span class="n">Zr</span> <span class="o">=</span> <span class="s2">&quot;Zr&quot;</span>
    <span class="n">Nb</span> <span class="o">=</span> <span class="s2">&quot;Nb&quot;</span>
    <span class="n">Mo</span> <span class="o">=</span> <span class="s2">&quot;Mo&quot;</span>
    <span class="n">Tc</span> <span class="o">=</span> <span class="s2">&quot;Tc&quot;</span>
    <span class="n">Ru</span> <span class="o">=</span> <span class="s2">&quot;Ru&quot;</span>
    <span class="n">Rh</span> <span class="o">=</span> <span class="s2">&quot;Rh&quot;</span>
    <span class="n">Pd</span> <span class="o">=</span> <span class="s2">&quot;Pd&quot;</span>
    <span class="n">Ag</span> <span class="o">=</span> <span class="s2">&quot;Ag&quot;</span>
    <span class="n">Cd</span> <span class="o">=</span> <span class="s2">&quot;Cd&quot;</span>
    <span class="n">In</span> <span class="o">=</span> <span class="s2">&quot;In&quot;</span>
    <span class="n">Sn</span> <span class="o">=</span> <span class="s2">&quot;Sn&quot;</span>
    <span class="n">Sb</span> <span class="o">=</span> <span class="s2">&quot;Sb&quot;</span>
    <span class="n">Te</span> <span class="o">=</span> <span class="s2">&quot;Te&quot;</span>
    <span class="n">I</span> <span class="o">=</span> <span class="s2">&quot;I&quot;</span>
    <span class="n">Xe</span> <span class="o">=</span> <span class="s2">&quot;Xe&quot;</span>
    <span class="n">Cs</span> <span class="o">=</span> <span class="s2">&quot;Cs&quot;</span>
    <span class="n">Ba</span> <span class="o">=</span> <span class="s2">&quot;Ba&quot;</span>
    <span class="n">La</span> <span class="o">=</span> <span class="s2">&quot;La&quot;</span>
    <span class="n">Ce</span> <span class="o">=</span> <span class="s2">&quot;Ce&quot;</span>
    <span class="n">Pr</span> <span class="o">=</span> <span class="s2">&quot;Pr&quot;</span>
    <span class="n">Nd</span> <span class="o">=</span> <span class="s2">&quot;Nd&quot;</span>
    <span class="n">Pm</span> <span class="o">=</span> <span class="s2">&quot;Pm&quot;</span>
    <span class="n">Sm</span> <span class="o">=</span> <span class="s2">&quot;Sm&quot;</span>
    <span class="n">Eu</span> <span class="o">=</span> <span class="s2">&quot;Eu&quot;</span>
    <span class="n">Gd</span> <span class="o">=</span> <span class="s2">&quot;Gd&quot;</span>
    <span class="n">Tb</span> <span class="o">=</span> <span class="s2">&quot;Tb&quot;</span>
    <span class="n">Dy</span> <span class="o">=</span> <span class="s2">&quot;Dy&quot;</span>
    <span class="n">Ho</span> <span class="o">=</span> <span class="s2">&quot;Ho&quot;</span>
    <span class="n">Er</span> <span class="o">=</span> <span class="s2">&quot;Er&quot;</span>
    <span class="n">Tm</span> <span class="o">=</span> <span class="s2">&quot;Tm&quot;</span>
    <span class="n">Yb</span> <span class="o">=</span> <span class="s2">&quot;Yb&quot;</span>
    <span class="n">Lu</span> <span class="o">=</span> <span class="s2">&quot;Lu&quot;</span>
    <span class="n">Hf</span> <span class="o">=</span> <span class="s2">&quot;Hf&quot;</span>
    <span class="n">Ta</span> <span class="o">=</span> <span class="s2">&quot;Ta&quot;</span>
    <span class="n">W</span> <span class="o">=</span> <span class="s2">&quot;W&quot;</span>
    <span class="n">Re</span> <span class="o">=</span> <span class="s2">&quot;Re&quot;</span>
    <span class="n">Os</span> <span class="o">=</span> <span class="s2">&quot;Os&quot;</span>
    <span class="n">Ir</span> <span class="o">=</span> <span class="s2">&quot;Ir&quot;</span>
    <span class="n">Pt</span> <span class="o">=</span> <span class="s2">&quot;Pt&quot;</span>
    <span class="n">Au</span> <span class="o">=</span> <span class="s2">&quot;Au&quot;</span>
    <span class="n">Hg</span> <span class="o">=</span> <span class="s2">&quot;Hg&quot;</span>
    <span class="n">Tl</span> <span class="o">=</span> <span class="s2">&quot;Tl&quot;</span>
    <span class="n">Pb</span> <span class="o">=</span> <span class="s2">&quot;Pb&quot;</span>
    <span class="n">Bi</span> <span class="o">=</span> <span class="s2">&quot;Bi&quot;</span>
    <span class="n">Po</span> <span class="o">=</span> <span class="s2">&quot;Po&quot;</span>
    <span class="n">At</span> <span class="o">=</span> <span class="s2">&quot;At&quot;</span>
    <span class="n">Rn</span> <span class="o">=</span> <span class="s2">&quot;Rn&quot;</span>
    <span class="n">Fr</span> <span class="o">=</span> <span class="s2">&quot;Fr&quot;</span>
    <span class="n">Ra</span> <span class="o">=</span> <span class="s2">&quot;Ra&quot;</span>
    <span class="n">Ac</span> <span class="o">=</span> <span class="s2">&quot;Ac&quot;</span>
    <span class="n">Th</span> <span class="o">=</span> <span class="s2">&quot;Th&quot;</span>
    <span class="n">Pa</span> <span class="o">=</span> <span class="s2">&quot;Pa&quot;</span>
    <span class="n">U</span> <span class="o">=</span> <span class="s2">&quot;U&quot;</span>
    <span class="n">Np</span> <span class="o">=</span> <span class="s2">&quot;Np&quot;</span>
    <span class="n">Pu</span> <span class="o">=</span> <span class="s2">&quot;Pu&quot;</span>
    <span class="n">Am</span> <span class="o">=</span> <span class="s2">&quot;Am&quot;</span>
    <span class="n">Cm</span> <span class="o">=</span> <span class="s2">&quot;Cm&quot;</span>
    <span class="n">Bk</span> <span class="o">=</span> <span class="s2">&quot;Bk&quot;</span>
    <span class="n">Cf</span> <span class="o">=</span> <span class="s2">&quot;Cf&quot;</span>
    <span class="n">Es</span> <span class="o">=</span> <span class="s2">&quot;Es&quot;</span>
    <span class="n">Fm</span> <span class="o">=</span> <span class="s2">&quot;Fm&quot;</span>
    <span class="n">Md</span> <span class="o">=</span> <span class="s2">&quot;Md&quot;</span>
    <span class="n">No</span> <span class="o">=</span> <span class="s2">&quot;No&quot;</span>
    <span class="n">Lr</span> <span class="o">=</span> <span class="s2">&quot;Lr&quot;</span>
    <span class="n">Rf</span> <span class="o">=</span> <span class="s2">&quot;Rf&quot;</span>
    <span class="n">Db</span> <span class="o">=</span> <span class="s2">&quot;Db&quot;</span>
    <span class="n">Sg</span> <span class="o">=</span> <span class="s2">&quot;Sg&quot;</span>
    <span class="n">Bh</span> <span class="o">=</span> <span class="s2">&quot;Bh&quot;</span>
    <span class="n">Hs</span> <span class="o">=</span> <span class="s2">&quot;Hs&quot;</span>
    <span class="n">Mt</span> <span class="o">=</span> <span class="s2">&quot;Mt&quot;</span>
    <span class="n">Ds</span> <span class="o">=</span> <span class="s2">&quot;Ds&quot;</span>
    <span class="n">Rg</span> <span class="o">=</span> <span class="s2">&quot;Rg&quot;</span>
    <span class="n">Cn</span> <span class="o">=</span> <span class="s2">&quot;Cn&quot;</span>
    <span class="n">Nh</span> <span class="o">=</span> <span class="s2">&quot;Nh&quot;</span>
    <span class="n">Fl</span> <span class="o">=</span> <span class="s2">&quot;Fl&quot;</span>
    <span class="n">Mc</span> <span class="o">=</span> <span class="s2">&quot;Mc&quot;</span>
    <span class="n">Lv</span> <span class="o">=</span> <span class="s2">&quot;Lv&quot;</span>
    <span class="n">Ts</span> <span class="o">=</span> <span class="s2">&quot;Ts&quot;</span>
    <span class="n">Og</span> <span class="o">=</span> <span class="s2">&quot;Og&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">symbol</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Basic immutable element object with all relevant properties.</span>

<span class="sd">        Only one instance of Element for each symbol is stored after creation,</span>
<span class="sd">        ensuring that a particular element behaves like a singleton. For all</span>
<span class="sd">        attributes, missing data (i.e., data for which is not available) is</span>
<span class="sd">        represented by a None unless otherwise stated.</span>

<span class="sd">        Args:</span>
<span class="sd">            symbol (str): Element symbol, e.g., &quot;H&quot;, &quot;Fe&quot;</span>

<span class="sd">        .. attribute:: Z</span>

<span class="sd">            Atomic number</span>

<span class="sd">        .. attribute:: symbol</span>

<span class="sd">            Element symbol</span>

<span class="sd">        .. attribute:: X</span>

<span class="sd">            Pauling electronegativity. Elements without an electronegativity</span>
<span class="sd">            number are assigned a value of zero by default.</span>

<span class="sd">        .. attribute:: number</span>

<span class="sd">            Alternative attribute for atomic number</span>

<span class="sd">        .. attribute:: max_oxidation_state</span>

<span class="sd">            Maximum oxidation state for element</span>

<span class="sd">        .. attribute:: min_oxidation_state</span>

<span class="sd">            Minimum oxidation state for element</span>

<span class="sd">        .. attribute:: oxidation_states</span>

<span class="sd">            Tuple of all known oxidation states</span>

<span class="sd">        .. attribute:: common_oxidation_states</span>

<span class="sd">            Tuple of all common oxidation states</span>

<span class="sd">        .. attribute:: full_electronic_structure</span>

<span class="sd">            Full electronic structure as tuple.</span>
<span class="sd">            E.g., The electronic structure for Fe is represented as:</span>
<span class="sd">            [(1, &quot;s&quot;, 2), (2, &quot;s&quot;, 2), (2, &quot;p&quot;, 6), (3, &quot;s&quot;, 2), (3, &quot;p&quot;, 6),</span>
<span class="sd">            (3, &quot;d&quot;, 6), (4, &quot;s&quot;, 2)]</span>

<span class="sd">        .. attribute:: row</span>

<span class="sd">            Returns the periodic table row of the element.</span>

<span class="sd">        .. attribute:: group</span>

<span class="sd">            Returns the periodic table group of the element.</span>

<span class="sd">        .. attribute:: block</span>

<span class="sd">            Return the block character &quot;s,p,d,f&quot;</span>

<span class="sd">        .. attribute:: is_noble_gas</span>

<span class="sd">            True if element is noble gas.</span>

<span class="sd">        .. attribute:: is_transition_metal</span>

<span class="sd">            True if element is a transition metal.</span>

<span class="sd">        .. attribute:: is_post_transition_metal</span>

<span class="sd">            True if element is a post transition metal.</span>

<span class="sd">        .. attribute:: is_rare_earth_metal</span>

<span class="sd">            True if element is a rare earth metal.</span>

<span class="sd">        .. attribute:: is_metalloid</span>

<span class="sd">            True if element is a metalloid.</span>

<span class="sd">        .. attribute:: is_alkali</span>

<span class="sd">            True if element is an alkali metal.</span>

<span class="sd">        .. attribute:: is_alkaline</span>

<span class="sd">            True if element is an alkaline earth metal (group II).</span>

<span class="sd">        .. attribute:: is_halogen</span>

<span class="sd">            True if element is a halogen.</span>

<span class="sd">        .. attribute:: is_lanthanoid</span>

<span class="sd">            True if element is a lanthanoid.</span>

<span class="sd">        .. attribute:: is_actinoid</span>

<span class="sd">            True if element is a actinoid.</span>

<span class="sd">        .. attribute:: iupac_ordering</span>

<span class="sd">            Ordering according to Table VI of &quot;Nomenclature of Inorganic Chemistry</span>
<span class="sd">            (IUPAC Recommendations 2005)&quot;. This ordering effectively follows the</span>
<span class="sd">            groups and rows of the periodic table, except the Lanthanides, Actanides</span>
<span class="sd">            and hydrogen.</span>

<span class="sd">        .. attribute:: long_name</span>

<span class="sd">           Long name for element. E.g., &quot;Hydrogen&quot;.</span>

<span class="sd">        .. attribute:: atomic_mass</span>

<span class="sd">            Atomic mass for the element.</span>

<span class="sd">        .. attribute:: atomic_radius</span>

<span class="sd">            Atomic radius for the element. This is the empirical value. Data is</span>
<span class="sd">            obtained from</span>
<span class="sd">            http://en.wikipedia.org/wiki/Atomic_radii_of_the_elements_(data_page).</span>

<span class="sd">        .. attribute:: atomic_radius_calculated</span>

<span class="sd">            Calculated atomic radius for the element. This is the empirical value.</span>
<span class="sd">            Data is obtained from</span>
<span class="sd">            http://en.wikipedia.org/wiki/Atomic_radii_of_the_elements_(data_page).</span>

<span class="sd">        .. attribute:: van_der_waals_radius</span>

<span class="sd">            Van der Waals radius for the element. This is the empirical</span>
<span class="sd">            value. Data is obtained from</span>
<span class="sd">            http://en.wikipedia.org/wiki/Atomic_radii_of_the_elements_(data_page).</span>

<span class="sd">        .. attribute:: mendeleev_no</span>

<span class="sd">            Mendeleev number from definition given by Pettifor, D. G. (1984).</span>
<span class="sd">            A chemical scale for crystal-structure maps. Solid State Communications,</span>
<span class="sd">            51 (1), 31-34 </span>

<span class="sd">        .. attribute:: electrical_resistivity</span>

<span class="sd">            Electrical resistivity</span>

<span class="sd">        .. attribute:: velocity_of_sound</span>

<span class="sd">            Velocity of sound</span>

<span class="sd">        .. attribute:: reflectivity</span>

<span class="sd">            Reflectivity</span>

<span class="sd">        .. attribute:: refractive_index</span>

<span class="sd">            Refractice index</span>

<span class="sd">        .. attribute:: poissons_ratio</span>

<span class="sd">            Poisson&#39;s ratio</span>

<span class="sd">        .. attribute:: molar_volume</span>

<span class="sd">            Molar volume</span>

<span class="sd">        .. attribute:: electronic_structure</span>

<span class="sd">            Electronic structure.</span>
<span class="sd">            E.g., The electronic structure for Fe is represented as</span>
<span class="sd">            [Ar].3d6.4s2</span>

<span class="sd">        .. attribute:: atomic_orbitals</span>

<span class="sd">            Atomic Orbitals. Energy of the atomic orbitals as a dict.</span>
<span class="sd">            E.g., The orbitals energies in eV are represented as</span>
<span class="sd">            {&#39;1s&#39;: -1.0, &#39;2s&#39;: -0.1}</span>
<span class="sd">            Data is obtained from</span>
<span class="sd">            https://www.nist.gov/pml/data/atomic-reference-data-electronic-structure-calculations</span>
<span class="sd">            The LDA values for neutral atoms are used</span>

<span class="sd">        .. attribute:: thermal_conductivity</span>

<span class="sd">            Thermal conductivity</span>

<span class="sd">        .. attribute:: boiling_point</span>

<span class="sd">            Boiling point</span>

<span class="sd">        .. attribute:: melting_point</span>

<span class="sd">            Melting point</span>

<span class="sd">        .. attribute:: critical_temperature</span>

<span class="sd">            Critical temperature</span>

<span class="sd">        .. attribute:: superconduction_temperature</span>

<span class="sd">            Superconduction temperature</span>

<span class="sd">        .. attribute:: liquid_range</span>

<span class="sd">            Liquid range</span>

<span class="sd">        .. attribute:: bulk_modulus</span>

<span class="sd">            Bulk modulus</span>

<span class="sd">        .. attribute:: youngs_modulus</span>

<span class="sd">            Young&#39;s modulus</span>

<span class="sd">        .. attribute:: brinell_hardness</span>

<span class="sd">            Brinell hardness</span>

<span class="sd">        .. attribute:: rigidity_modulus</span>

<span class="sd">            Rigidity modulus</span>

<span class="sd">        .. attribute:: mineral_hardness</span>

<span class="sd">            Mineral hardness</span>

<span class="sd">        .. attribute:: vickers_hardness</span>

<span class="sd">            Vicker&#39;s hardness</span>

<span class="sd">        .. attribute:: density_of_solid</span>

<span class="sd">            Density of solid phase</span>

<span class="sd">        .. attribute:: coefficient_of_linear_thermal_expansion</span>

<span class="sd">            Coefficient of linear thermal expansion</span>

<span class="sd">        .. attribute:: average_ionic_radius</span>

<span class="sd">            Average ionic radius for element in ang. The average is taken over all</span>
<span class="sd">            oxidation states of the element for which data is present.</span>

<span class="sd">        .. attribute:: average_cationic_radius</span>

<span class="sd">            Average cationic radius for element in ang. The average is taken over all</span>
<span class="sd">            positive oxidation states of the element for which data is present.</span>

<span class="sd">        .. attribute:: average_anionic_radius</span>

<span class="sd">            Average ionic radius for element in ang. The average is taken over all</span>
<span class="sd">            negative oxidation states of the element for which data is present.</span>

<span class="sd">        .. attribute:: ionic_radii</span>

<span class="sd">            All ionic radii of the element as a dict of</span>
<span class="sd">            {oxidation state: ionic radii}. Radii are given in ang.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">symbol</span>
        <span class="n">d</span> <span class="o">=</span> <span class="n">_pt_data</span><span class="p">[</span><span class="n">symbol</span><span class="p">]</span>

        <span class="c1"># Store key variables for quick access</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s2">&quot;Atomic no&quot;</span><span class="p">]</span>

        <span class="n">at_r</span> <span class="o">=</span> <span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;Atomic radius&quot;</span><span class="p">,</span> <span class="s2">&quot;no data&quot;</span><span class="p">)</span>
        <span class="k">if</span> <span class="nb">str</span><span class="p">(</span><span class="n">at_r</span><span class="p">)</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;no data&quot;</span><span class="p">):</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_atomic_radius</span> <span class="o">=</span> <span class="kc">None</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_atomic_radius</span> <span class="o">=</span> <span class="n">Length</span><span class="p">(</span><span class="n">at_r</span><span class="p">,</span> <span class="s2">&quot;ang&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_atomic_mass</span> <span class="o">=</span> <span class="n">Mass</span><span class="p">(</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;Atomic mass&quot;</span><span class="p">],</span> <span class="s2">&quot;amu&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">long_name</span> <span class="o">=</span> <span class="n">d</span><span class="p">[</span><span class="s2">&quot;Name&quot;</span><span class="p">]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_data</span> <span class="o">=</span> <span class="n">d</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">X</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Electronegativity of element. Note that if an element does not</span>
<span class="sd">            have an electronegativity, a NaN float is returned.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="s2">&quot;X&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">[</span><span class="s2">&quot;X&quot;</span><span class="p">]</span>
        <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;No electronegativity for </span><span class="si">%s</span><span class="s2">. Setting to NaN. &quot;</span>
                      <span class="s2">&quot;This has no physical meaning, and is mainly done to &quot;</span>
                      <span class="s2">&quot;avoid errors caused by the code expecting a float.&quot;</span>
                      <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span><span class="p">)</span>
        <span class="k">return</span> <span class="nb">float</span><span class="p">(</span><span class="s2">&quot;NaN&quot;</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">atomic_radius</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns: The atomic radius of the element in Ångstroms.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_atomic_radius</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">atomic_mass</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns: The atomic mass of the element in amu.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_atomic_mass</span>

    <span class="k">def</span> <span class="fm">__getattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">item</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;mendeleev_no&quot;</span><span class="p">,</span> <span class="s2">&quot;electrical_resistivity&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;velocity_of_sound&quot;</span><span class="p">,</span> <span class="s2">&quot;reflectivity&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;refractive_index&quot;</span><span class="p">,</span> <span class="s2">&quot;poissons_ratio&quot;</span><span class="p">,</span> <span class="s2">&quot;molar_volume&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;thermal_conductivity&quot;</span><span class="p">,</span> <span class="s2">&quot;boiling_point&quot;</span><span class="p">,</span> <span class="s2">&quot;melting_point&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;critical_temperature&quot;</span><span class="p">,</span> <span class="s2">&quot;superconduction_temperature&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;liquid_range&quot;</span><span class="p">,</span> <span class="s2">&quot;bulk_modulus&quot;</span><span class="p">,</span> <span class="s2">&quot;youngs_modulus&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;brinell_hardness&quot;</span><span class="p">,</span> <span class="s2">&quot;rigidity_modulus&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;mineral_hardness&quot;</span><span class="p">,</span> <span class="s2">&quot;vickers_hardness&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;density_of_solid&quot;</span><span class="p">,</span> <span class="s2">&quot;atomic_radius_calculated&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;van_der_waals_radius&quot;</span><span class="p">,</span> <span class="s2">&quot;atomic_orbitals&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;coefficient_of_linear_thermal_expansion&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;ground_state_term_symbol&quot;</span><span class="p">,</span> <span class="s2">&quot;valence&quot;</span><span class="p">]:</span>
            <span class="n">kstr</span> <span class="o">=</span> <span class="n">item</span><span class="o">.</span><span class="n">capitalize</span><span class="p">()</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;_&quot;</span><span class="p">,</span> <span class="s2">&quot; &quot;</span><span class="p">)</span>
            <span class="n">val</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">kstr</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
            <span class="k">if</span> <span class="nb">str</span><span class="p">(</span><span class="n">val</span><span class="p">)</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s2">&quot;no data&quot;</span><span class="p">):</span>
                <span class="n">val</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">val</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
                <span class="k">pass</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="k">try</span><span class="p">:</span>
                    <span class="n">val</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">val</span><span class="p">)</span>
                <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
                    <span class="n">nobracket</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;\(.*\)&#39;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="n">val</span><span class="p">)</span>
                    <span class="n">toks</span> <span class="o">=</span> <span class="n">nobracket</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;about&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">strip</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">toks</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                        <span class="k">try</span><span class="p">:</span>
                            <span class="k">if</span> <span class="s2">&quot;10&lt;sup&gt;&quot;</span> <span class="ow">in</span> <span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">]:</span>
                                <span class="n">base_power</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="sa">r</span><span class="s1">&#39;([+-]?\d+)&#39;</span><span class="p">,</span> <span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
                                <span class="n">factor</span> <span class="o">=</span> <span class="s2">&quot;e&quot;</span> <span class="o">+</span> <span class="n">base_power</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                                <span class="k">if</span> <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;&amp;gt;&quot;</span><span class="p">,</span> <span class="s2">&quot;high&quot;</span><span class="p">]:</span>
                                    <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;1&quot;</span>  <span class="c1"># return the border value</span>
                                <span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+=</span> <span class="n">factor</span>
                                <span class="k">if</span> <span class="n">item</span> <span class="o">==</span> <span class="s2">&quot;electrical_resistivity&quot;</span><span class="p">:</span>
                                    <span class="n">unit</span> <span class="o">=</span> <span class="s2">&quot;ohm m&quot;</span>
                                <span class="k">elif</span> <span class="n">item</span> <span class="o">==</span> <span class="s2">&quot;coefficient_of_linear_thermal_expansion&quot;</span><span class="p">:</span>
                                    <span class="n">unit</span> <span class="o">=</span> <span class="s2">&quot;K^-1&quot;</span>
                                <span class="k">else</span><span class="p">:</span>
                                    <span class="n">unit</span> <span class="o">=</span> <span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                                <span class="n">val</span> <span class="o">=</span> <span class="n">FloatWithUnit</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">unit</span><span class="p">)</span>
                            <span class="k">else</span><span class="p">:</span>
                                <span class="n">unit</span> <span class="o">=</span> <span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;&lt;sup&gt;&quot;</span><span class="p">,</span> <span class="s2">&quot;^&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span>
                                    <span class="s2">&quot;&lt;/sup&gt;&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;&amp;Omega;&quot;</span><span class="p">,</span>
                                                          <span class="s2">&quot;ohm&quot;</span><span class="p">)</span>
                                <span class="n">units</span> <span class="o">=</span> <span class="n">Unit</span><span class="p">(</span><span class="n">unit</span><span class="p">)</span>
                                <span class="k">if</span> <span class="nb">set</span><span class="p">(</span><span class="n">units</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span><span class="o">.</span><span class="n">issubset</span><span class="p">(</span>
                                        <span class="n">SUPPORTED_UNIT_NAMES</span><span class="p">):</span>
                                    <span class="n">val</span> <span class="o">=</span> <span class="n">FloatWithUnit</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">unit</span><span class="p">)</span>
                        <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
                            <span class="c1"># Ignore error. val will just remain a string.</span>
                            <span class="k">pass</span>
            <span class="k">return</span> <span class="n">val</span>
        <span class="k">raise</span> <span class="ne">AttributeError</span><span class="p">(</span><span class="s2">&quot;Element has no attribute </span><span class="si">%s</span><span class="s2">!&quot;</span> <span class="o">%</span> <span class="n">item</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">data</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">dict</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns dict of data for element.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">copy</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">electronic_structure</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Electronic structure as string, with only valence electrons.</span>
<span class="sd">        E.g., The electronic structure for Fe is represented as &#39;[Ar].3d6.4s2&#39;</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">re</span><span class="o">.</span><span class="n">sub</span><span class="p">(</span><span class="s2">&quot;&lt;/*sup&gt;&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">[</span><span class="s2">&quot;Electronic structure&quot;</span><span class="p">])</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">average_ionic_radius</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Average ionic radius for element (with units). The average is taken</span>
<span class="sd">        over all oxidation states of the element for which data is present.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="s2">&quot;Ionic radii&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">:</span>
            <span class="n">radii</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">[</span><span class="s2">&quot;Ionic radii&quot;</span><span class="p">]</span>
            <span class="n">radius</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">(</span><span class="n">radii</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> <span class="o">/</span> <span class="nb">len</span><span class="p">(</span><span class="n">radii</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">radius</span> <span class="o">=</span> <span class="mf">0.0</span>
        <span class="k">return</span> <span class="n">FloatWithUnit</span><span class="p">(</span><span class="n">radius</span><span class="p">,</span> <span class="s2">&quot;ang&quot;</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">average_cationic_radius</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Average cationic radius for element (with units). The average is</span>
<span class="sd">        taken over all positive oxidation states of the element for which</span>
<span class="sd">        data is present.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="s2">&quot;Ionic radii&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">:</span>
            <span class="n">radii</span> <span class="o">=</span> <span class="p">[</span><span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">[</span><span class="s2">&quot;Ionic radii&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">()</span>
                     <span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">]</span>
            <span class="k">if</span> <span class="n">radii</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">FloatWithUnit</span><span class="p">(</span><span class="nb">sum</span><span class="p">(</span><span class="n">radii</span><span class="p">)</span> <span class="o">/</span> <span class="nb">len</span><span class="p">(</span><span class="n">radii</span><span class="p">),</span> <span class="s2">&quot;ang&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">FloatWithUnit</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="s2">&quot;ang&quot;</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">average_anionic_radius</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Average anionic radius for element (with units). The average is</span>
<span class="sd">        taken over all negative oxidation states of the element for which</span>
<span class="sd">        data is present.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="s2">&quot;Ionic radii&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">:</span>
            <span class="n">radii</span> <span class="o">=</span> <span class="p">[</span><span class="n">v</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">[</span><span class="s2">&quot;Ionic radii&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">()</span>
                     <span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">]</span>
            <span class="k">if</span> <span class="n">radii</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">FloatWithUnit</span><span class="p">(</span><span class="nb">sum</span><span class="p">(</span><span class="n">radii</span><span class="p">)</span> <span class="o">/</span> <span class="nb">len</span><span class="p">(</span><span class="n">radii</span><span class="p">),</span> <span class="s2">&quot;ang&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">FloatWithUnit</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span> <span class="s2">&quot;ang&quot;</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">ionic_radii</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        All ionic radii of the element as a dict of</span>
<span class="sd">        {oxidation state: ionic radii}. Radii are given in ang.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="s2">&quot;Ionic radii&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">{</span><span class="nb">int</span><span class="p">(</span><span class="n">k</span><span class="p">):</span> <span class="n">FloatWithUnit</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="s2">&quot;ang&quot;</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">[</span><span class="s2">&quot;Ionic radii&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span>
        <span class="k">return</span> <span class="p">{}</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">number</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Alternative attribute for atomic number&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">max_oxidation_state</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Maximum oxidation state for element&quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="s2">&quot;Oxidation states&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">max</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">[</span><span class="s2">&quot;Oxidation states&quot;</span><span class="p">])</span>
        <span class="k">return</span> <span class="mi">0</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">min_oxidation_state</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Minimum oxidation state for element&quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="s2">&quot;Oxidation states&quot;</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">:</span>
            <span class="k">return</span> <span class="nb">min</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">[</span><span class="s2">&quot;Oxidation states&quot;</span><span class="p">])</span>
        <span class="k">return</span> <span class="mi">0</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">oxidation_states</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Tuple of all known oxidation states&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;Oxidation states&quot;</span><span class="p">,</span> <span class="nb">list</span><span class="p">()))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">common_oxidation_states</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Tuple of all known oxidation states&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;Common oxidation states&quot;</span><span class="p">,</span> <span class="nb">list</span><span class="p">()))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">icsd_oxidation_states</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Tuple of all oxidation states with at least 10 instances in</span>
<span class="sd">        ICSD database AND at least 1% of entries for that element&quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="nb">tuple</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;ICSD oxidation states&quot;</span><span class="p">,</span> <span class="nb">list</span><span class="p">()))</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">metallic_radius</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Metallic radius of the element. Radius is given in ang.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">FloatWithUnit</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">[</span><span class="s2">&quot;Metallic radius&quot;</span><span class="p">],</span> <span class="s2">&quot;ang&quot;</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">full_electronic_structure</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Full electronic structure as tuple.</span>
<span class="sd">        E.g., The electronic structure for Fe is represented as:</span>
<span class="sd">        [(1, &quot;s&quot;, 2), (2, &quot;s&quot;, 2), (2, &quot;p&quot;, 6), (3, &quot;s&quot;, 2), (3, &quot;p&quot;, 6),</span>
<span class="sd">        (3, &quot;d&quot;, 6), (4, &quot;s&quot;, 2)]</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">estr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">electronic_structure</span>

        <span class="k">def</span> <span class="nf">parse_orbital</span><span class="p">(</span><span class="n">orbstr</span><span class="p">):</span>
            <span class="n">m</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">match</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;(\d+)([spdfg]+)(\d+)&quot;</span><span class="p">,</span> <span class="n">orbstr</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
                <span class="k">return</span> <span class="nb">int</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)),</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span> <span class="nb">int</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">3</span><span class="p">))</span>
            <span class="k">return</span> <span class="n">orbstr</span>

        <span class="n">data</span> <span class="o">=</span> <span class="p">[</span><span class="n">parse_orbital</span><span class="p">(</span><span class="n">s</span><span class="p">)</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">estr</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;.&quot;</span><span class="p">)]</span>
        <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;[&quot;</span><span class="p">:</span>
            <span class="n">sym</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;[&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;]&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">)</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">Element</span><span class="p">(</span><span class="n">sym</span><span class="p">)</span><span class="o">.</span><span class="n">full_electronic_structure</span> <span class="o">+</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span><span class="p">:]</span>
        <span class="k">return</span> <span class="n">data</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">valence</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        # From full electron config obtain valence subshell</span>
<span class="sd">        # angular moment (L) and number of valence e- (v_e)</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># the number of valence of noble gas is 0</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">group</span> <span class="o">==</span> <span class="mi">18</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">nan</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>

        <span class="n">L_symbols</span> <span class="o">=</span> <span class="s1">&#39;SPDFGHIKLMNOQRTUVWXYZ&#39;</span>
        <span class="n">valence</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">full_electron_config</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">full_electronic_structure</span>
        <span class="k">for</span> <span class="n">_</span><span class="p">,</span> <span class="n">l_symbol</span><span class="p">,</span> <span class="n">ne</span> <span class="ow">in</span> <span class="n">full_electron_config</span><span class="p">[::</span><span class="o">-</span><span class="mi">1</span><span class="p">]:</span>
            <span class="n">l</span> <span class="o">=</span> <span class="n">L_symbols</span><span class="o">.</span><span class="n">lower</span><span class="p">()</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">l_symbol</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">ne</span> <span class="o">&lt;</span> <span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">l</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="mi">2</span><span class="p">:</span>
                <span class="n">valence</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">l</span><span class="p">,</span> <span class="n">ne</span><span class="p">))</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">valence</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Ambiguous valence&quot;</span><span class="p">)</span>

        <span class="k">return</span> <span class="n">valence</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">term_symbols</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        All possible  Russell-Saunders term symbol of the Element</span>
<span class="sd">        eg. L = 1, n_e = 2 (s2)</span>
<span class="sd">        returns</span>
<span class="sd">           [[&#39;1D2&#39;], [&#39;3P0&#39;, &#39;3P1&#39;, &#39;3P2&#39;], [&#39;1S0&#39;]]</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">L_symbols</span> <span class="o">=</span> <span class="s1">&#39;SPDFGHIKLMNOQRTUVWXYZ&#39;</span>

        <span class="n">L</span><span class="p">,</span> <span class="n">v_e</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">valence</span>

        <span class="c1"># for one electron in subshell L</span>
        <span class="n">ml</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="o">-</span><span class="n">L</span><span class="p">,</span> <span class="n">L</span> <span class="o">+</span> <span class="mi">1</span><span class="p">))</span>
        <span class="n">ms</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span> <span class="o">/</span> <span class="mi">2</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span> <span class="o">/</span> <span class="mi">2</span><span class="p">]</span>
        <span class="c1"># all possible configurations of ml,ms for one e in subshell L</span>
        <span class="n">ml_ms</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">product</span><span class="p">(</span><span class="n">ml</span><span class="p">,</span> <span class="n">ms</span><span class="p">))</span>

        <span class="c1"># Number of possible configurations for r electrons in subshell L.</span>
        <span class="n">n</span> <span class="o">=</span> <span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">L</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="mi">2</span>
        <span class="c1"># the combination of n_e electrons configurations</span>
        <span class="c1"># C^{n}_{n_e}</span>
        <span class="n">e_config_combs</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">combinations</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="n">n</span><span class="p">),</span> <span class="n">v_e</span><span class="p">))</span>

        <span class="c1"># Total ML = sum(ml1, ml2), Total MS = sum(ms1, ms2)</span>
        <span class="n">TL</span> <span class="o">=</span> <span class="p">[</span><span class="nb">sum</span><span class="p">([</span><span class="n">ml_ms</span><span class="p">[</span><span class="n">comb</span><span class="p">[</span><span class="n">e</span><span class="p">]][</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">v_e</span><span class="p">)])</span>
              <span class="k">for</span> <span class="n">comb</span> <span class="ow">in</span> <span class="n">e_config_combs</span><span class="p">]</span>
        <span class="n">TS</span> <span class="o">=</span> <span class="p">[</span><span class="nb">sum</span><span class="p">([</span><span class="n">ml_ms</span><span class="p">[</span><span class="n">comb</span><span class="p">[</span><span class="n">e</span><span class="p">]][</span><span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">v_e</span><span class="p">)])</span>
              <span class="k">for</span> <span class="n">comb</span> <span class="ow">in</span> <span class="n">e_config_combs</span><span class="p">]</span>
        <span class="n">comb_counter</span> <span class="o">=</span> <span class="n">Counter</span><span class="p">([</span><span class="n">r</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="nb">zip</span><span class="p">(</span><span class="n">TL</span><span class="p">,</span> <span class="n">TS</span><span class="p">)])</span>

        <span class="n">term_symbols</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">while</span> <span class="nb">sum</span><span class="p">(</span><span class="n">comb_counter</span><span class="o">.</span><span class="n">values</span><span class="p">())</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
            <span class="c1"># Start from the lowest freq combination,</span>
            <span class="c1"># which corresponds to largest abs(L) and smallest abs(S)</span>
            <span class="n">L</span><span class="p">,</span> <span class="n">S</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">comb_counter</span><span class="p">)</span>

            <span class="n">J</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="nb">abs</span><span class="p">(</span><span class="n">L</span> <span class="o">-</span> <span class="n">S</span><span class="p">),</span> <span class="nb">abs</span><span class="p">(</span><span class="n">L</span><span class="p">)</span> <span class="o">+</span> <span class="nb">abs</span><span class="p">(</span><span class="n">S</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span><span class="p">))</span>
            <span class="n">term_symbols</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="nb">str</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="p">(</span><span class="nb">abs</span><span class="p">(</span><span class="n">S</span><span class="p">))</span> <span class="o">+</span> <span class="mi">1</span><span class="p">))</span> <span class="o">+</span> <span class="n">L_symbols</span><span class="p">[</span><span class="nb">abs</span><span class="p">(</span><span class="n">L</span><span class="p">)]</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">j</span><span class="p">)</span> <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="n">J</span><span class="p">])</span>
            <span class="c1"># Without J</span>
            <span class="c1"># term_symbols.append(str(int(2 * (abs(S)) + 1)) \</span>
            <span class="c1">#                     + L_symbols[abs(L)])</span>

            <span class="c1"># Delete all configurations included in this term</span>
            <span class="k">for</span> <span class="n">ML</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="o">-</span><span class="n">L</span><span class="p">,</span> <span class="n">L</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">):</span>
                <span class="k">for</span> <span class="n">MS</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="n">S</span><span class="p">,</span> <span class="o">-</span><span class="n">S</span> <span class="o">+</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span>
                    <span class="k">if</span> <span class="p">(</span><span class="n">ML</span><span class="p">,</span> <span class="n">MS</span><span class="p">)</span> <span class="ow">in</span> <span class="n">comb_counter</span><span class="p">:</span>

                        <span class="n">comb_counter</span><span class="p">[(</span><span class="n">ML</span><span class="p">,</span> <span class="n">MS</span><span class="p">)]</span> <span class="o">-=</span> <span class="mi">1</span>
                        <span class="k">if</span> <span class="n">comb_counter</span><span class="p">[(</span><span class="n">ML</span><span class="p">,</span> <span class="n">MS</span><span class="p">)]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                            <span class="k">del</span> <span class="n">comb_counter</span><span class="p">[(</span><span class="n">ML</span><span class="p">,</span> <span class="n">MS</span><span class="p">)]</span>
        <span class="k">return</span> <span class="n">term_symbols</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">ground_state_term_symbol</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Ground state term symbol</span>
<span class="sd">        Selected based on Hund&#39;s Rule</span>

<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">L_symbols</span> <span class="o">=</span> <span class="s1">&#39;SPDFGHIKLMNOQRTUVWXYZ&#39;</span>

        <span class="n">term_symbols</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">term_symbols</span>
        <span class="n">term_symbol_flat</span> <span class="o">=</span> <span class="p">{</span><span class="n">term</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;multiplicity&quot;</span><span class="p">:</span> <span class="nb">int</span><span class="p">(</span><span class="n">term</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span>
                                   <span class="s2">&quot;L&quot;</span><span class="p">:</span> <span class="n">L_symbols</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">term</span><span class="p">[</span><span class="mi">1</span><span class="p">]),</span>
                                   <span class="s2">&quot;J&quot;</span><span class="p">:</span> <span class="nb">float</span><span class="p">(</span><span class="n">term</span><span class="p">[</span><span class="mi">2</span><span class="p">:])}</span>
                            <span class="k">for</span> <span class="n">term</span> <span class="ow">in</span> <span class="nb">sum</span><span class="p">(</span><span class="n">term_symbols</span><span class="p">,</span> <span class="p">[])}</span>

        <span class="n">multi</span> <span class="o">=</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;multiplicity&#39;</span><span class="p">])</span>
                 <span class="k">for</span> <span class="n">terms</span><span class="p">,</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">term_symbol_flat</span><span class="o">.</span><span class="n">items</span><span class="p">()]</span>
        <span class="n">max_multi_terms</span> <span class="o">=</span> <span class="p">{</span><span class="n">symbol</span><span class="p">:</span> <span class="n">item</span>
                           <span class="k">for</span> <span class="n">symbol</span><span class="p">,</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">term_symbol_flat</span><span class="o">.</span><span class="n">items</span><span class="p">()</span>
                           <span class="k">if</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;multiplicity&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="nb">max</span><span class="p">(</span><span class="n">multi</span><span class="p">)}</span>

        <span class="n">Ls</span> <span class="o">=</span> <span class="p">[</span><span class="n">item</span><span class="p">[</span><span class="s1">&#39;L&#39;</span><span class="p">]</span> <span class="k">for</span> <span class="n">terms</span><span class="p">,</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">max_multi_terms</span><span class="o">.</span><span class="n">items</span><span class="p">()]</span>
        <span class="n">max_L_terms</span> <span class="o">=</span> <span class="p">{</span><span class="n">symbol</span><span class="p">:</span> <span class="n">item</span>
                       <span class="k">for</span> <span class="n">symbol</span><span class="p">,</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">term_symbol_flat</span><span class="o">.</span><span class="n">items</span><span class="p">()</span>
                       <span class="k">if</span> <span class="n">item</span><span class="p">[</span><span class="s1">&#39;L&#39;</span><span class="p">]</span> <span class="o">==</span> <span class="nb">max</span><span class="p">(</span><span class="n">Ls</span><span class="p">)}</span>

        <span class="n">J_sorted_terms</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">max_L_terms</span><span class="o">.</span><span class="n">items</span><span class="p">(),</span>
                                <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">k</span><span class="p">:</span> <span class="n">k</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="s1">&#39;J&#39;</span><span class="p">])</span>
        <span class="n">L</span><span class="p">,</span> <span class="n">v_e</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">valence</span>
        <span class="k">if</span> <span class="n">v_e</span> <span class="o">&lt;=</span> <span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">L</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">J_sorted_terms</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>
        <span class="k">return</span> <span class="n">J_sorted_terms</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span>

    <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="k">return</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="n">Element</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">Z</span>

    <span class="k">def</span> <span class="fm">__ne__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="k">return</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__eq__</span><span class="p">(</span><span class="n">other</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s2">&quot;Element &quot;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span>

    <span class="k">def</span> <span class="fm">__lt__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Sets a default sort order for atomic species by electronegativity. Very</span>
<span class="sd">        useful for getting correct formulas.  For example, FeO4PLi is</span>
<span class="sd">        automatically sorted into LiFePO4.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">x1</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="s2">&quot;inf&quot;</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span>
        <span class="n">x2</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="s2">&quot;inf&quot;</span><span class="p">)</span> <span class="k">if</span> <span class="n">other</span><span class="o">.</span><span class="n">X</span> <span class="o">!=</span> <span class="n">other</span><span class="o">.</span><span class="n">X</span> <span class="k">else</span> <span class="n">other</span><span class="o">.</span><span class="n">X</span>
        <span class="k">if</span> <span class="n">x1</span> <span class="o">!=</span> <span class="n">x2</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">x1</span> <span class="o">&lt;</span> <span class="n">x2</span>

        <span class="c1"># There are cases where the electronegativity are exactly equal.</span>
        <span class="c1"># We then sort by symbol.</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span> <span class="o">&lt;</span> <span class="n">other</span><span class="o">.</span><span class="n">symbol</span>

<div class="viewcode-block" id="Element.from_Z"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Element.from_Z">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">from_Z</span><span class="p">(</span><span class="n">z</span><span class="p">:</span> <span class="nb">int</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get an element from an atomic number.</span>

<span class="sd">        Args:</span>
<span class="sd">            z (int): Atomic number</span>

<span class="sd">        Returns:</span>
<span class="sd">            Element with atomic number z.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">for</span> <span class="n">sym</span><span class="p">,</span> <span class="n">data</span> <span class="ow">in</span> <span class="n">_pt_data</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">data</span><span class="p">[</span><span class="s2">&quot;Atomic no&quot;</span><span class="p">]</span> <span class="o">==</span> <span class="n">z</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">Element</span><span class="p">(</span><span class="n">sym</span><span class="p">)</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;No element with this atomic number </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="n">z</span><span class="p">)</span></div>

<div class="viewcode-block" id="Element.from_row_and_group"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Element.from_row_and_group">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">from_row_and_group</span><span class="p">(</span><span class="n">row</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span> <span class="n">group</span><span class="p">:</span> <span class="nb">int</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns an element from a row and group number.</span>

<span class="sd">        Args:</span>
<span class="sd">            row (int): Row number</span>
<span class="sd">            group (int): Group number</span>

<span class="sd">        .. note::</span>
<span class="sd">            The 18 group number system is used, i.e., Noble gases are group 18.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">for</span> <span class="n">sym</span> <span class="ow">in</span> <span class="n">_pt_data</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
            <span class="n">el</span> <span class="o">=</span> <span class="n">Element</span><span class="p">(</span><span class="n">sym</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">el</span><span class="o">.</span><span class="n">row</span> <span class="o">==</span> <span class="n">row</span> <span class="ow">and</span> <span class="n">el</span><span class="o">.</span><span class="n">group</span> <span class="o">==</span> <span class="n">group</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">el</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;No element with this row and group!&quot;</span><span class="p">)</span></div>

<div class="viewcode-block" id="Element.is_valid_symbol"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Element.is_valid_symbol">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">is_valid_symbol</span><span class="p">(</span><span class="n">symbol</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns true if symbol is a valid element symbol.</span>

<span class="sd">        Args:</span>
<span class="sd">            symbol (str): Element symbol</span>

<span class="sd">        Returns:</span>
<span class="sd">            True if symbol is a valid element (e.g., &quot;H&quot;). False otherwise</span>
<span class="sd">            (e.g., &quot;Zebra&quot;).</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">symbol</span> <span class="ow">in</span> <span class="n">Element</span><span class="o">.</span><span class="n">__members__</span></div>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">row</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns the periodic table row of the element.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">z</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span>
        <span class="n">total</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="k">if</span> <span class="mi">57</span> <span class="o">&lt;=</span> <span class="n">z</span> <span class="o">&lt;=</span> <span class="mi">71</span><span class="p">:</span>
            <span class="k">return</span> <span class="mi">8</span>
        <span class="k">if</span> <span class="mi">89</span> <span class="o">&lt;=</span> <span class="n">z</span> <span class="o">&lt;=</span> <span class="mi">103</span><span class="p">:</span>
            <span class="k">return</span> <span class="mi">9</span>
        <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">size</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">_pt_row_sizes</span><span class="p">):</span>
            <span class="n">total</span> <span class="o">+=</span> <span class="n">size</span>
            <span class="k">if</span> <span class="n">total</span> <span class="o">&gt;=</span> <span class="n">z</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">i</span> <span class="o">+</span> <span class="mi">1</span>
        <span class="k">return</span> <span class="mi">8</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">group</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns the periodic table group of the element.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">z</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span>
        <span class="k">if</span> <span class="n">z</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">return</span> <span class="mi">1</span>
        <span class="k">if</span> <span class="n">z</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
            <span class="k">return</span> <span class="mi">18</span>
        <span class="k">if</span> <span class="mi">3</span> <span class="o">&lt;=</span> <span class="n">z</span> <span class="o">&lt;=</span> <span class="mi">18</span><span class="p">:</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">z</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span> <span class="o">%</span> <span class="mi">8</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="k">return</span> <span class="mi">18</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">z</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span> <span class="o">%</span> <span class="mi">8</span> <span class="o">&lt;=</span> <span class="mi">2</span><span class="p">:</span>
                <span class="k">return</span> <span class="p">(</span><span class="n">z</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span> <span class="o">%</span> <span class="mi">8</span>
            <span class="k">return</span> <span class="mi">10</span> <span class="o">+</span> <span class="p">(</span><span class="n">z</span> <span class="o">-</span> <span class="mi">2</span><span class="p">)</span> <span class="o">%</span> <span class="mi">8</span>

        <span class="k">if</span> <span class="mi">19</span> <span class="o">&lt;=</span> <span class="n">z</span> <span class="o">&lt;=</span> <span class="mi">54</span><span class="p">:</span>
            <span class="k">if</span> <span class="p">(</span><span class="n">z</span> <span class="o">-</span> <span class="mi">18</span><span class="p">)</span> <span class="o">%</span> <span class="mi">18</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="k">return</span> <span class="mi">18</span>
            <span class="k">return</span> <span class="p">(</span><span class="n">z</span> <span class="o">-</span> <span class="mi">18</span><span class="p">)</span> <span class="o">%</span> <span class="mi">18</span>

        <span class="k">if</span> <span class="p">(</span><span class="n">z</span> <span class="o">-</span> <span class="mi">54</span><span class="p">)</span> <span class="o">%</span> <span class="mi">32</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">return</span> <span class="mi">18</span>
        <span class="k">if</span> <span class="p">(</span><span class="n">z</span> <span class="o">-</span> <span class="mi">54</span><span class="p">)</span> <span class="o">%</span> <span class="mi">32</span> <span class="o">&gt;=</span> <span class="mi">18</span><span class="p">:</span>
            <span class="k">return</span> <span class="p">(</span><span class="n">z</span> <span class="o">-</span> <span class="mi">54</span><span class="p">)</span> <span class="o">%</span> <span class="mi">32</span> <span class="o">-</span> <span class="mi">14</span>
        <span class="k">return</span> <span class="p">(</span><span class="n">z</span> <span class="o">-</span> <span class="mi">54</span><span class="p">)</span> <span class="o">%</span> <span class="mi">32</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">block</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Return the block character &quot;s,p,d,f&quot;</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">is_actinoid</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_lanthanoid</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">71</span><span class="p">,</span> <span class="mi">103</span><span class="p">]:</span>
            <span class="k">return</span> <span class="s2">&quot;f&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_actinoid</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_lanthanoid</span><span class="p">:</span>
            <span class="k">return</span> <span class="s2">&quot;d&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">group</span> <span class="ow">in</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">]:</span>
            <span class="k">return</span> <span class="s2">&quot;s&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">group</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">13</span><span class="p">,</span> <span class="mi">19</span><span class="p">):</span>
            <span class="k">return</span> <span class="s2">&quot;p&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">group</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">13</span><span class="p">):</span>
            <span class="k">return</span> <span class="s2">&quot;d&quot;</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;unable to determine block&quot;</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_noble_gas</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        True if element is noble gas.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="ow">in</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">18</span><span class="p">,</span> <span class="mi">36</span><span class="p">,</span> <span class="mi">54</span><span class="p">,</span> <span class="mi">86</span><span class="p">,</span> <span class="mi">118</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_transition_metal</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        True if element is a transition metal.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">ns</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">21</span><span class="p">,</span> <span class="mi">31</span><span class="p">))</span>
        <span class="n">ns</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">39</span><span class="p">,</span> <span class="mi">49</span><span class="p">)))</span>
        <span class="n">ns</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">57</span><span class="p">)</span>
        <span class="n">ns</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">72</span><span class="p">,</span> <span class="mi">81</span><span class="p">)))</span>
        <span class="n">ns</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="mi">89</span><span class="p">)</span>
        <span class="n">ns</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="nb">list</span><span class="p">(</span><span class="nb">range</span><span class="p">(</span><span class="mi">104</span><span class="p">,</span> <span class="mi">113</span><span class="p">)))</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="ow">in</span> <span class="n">ns</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_post_transition_metal</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        True if element is a post-transition or poor metal.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;Al&quot;</span><span class="p">,</span> <span class="s2">&quot;Ga&quot;</span><span class="p">,</span> <span class="s2">&quot;In&quot;</span><span class="p">,</span> <span class="s2">&quot;Tl&quot;</span><span class="p">,</span> <span class="s2">&quot;Sn&quot;</span><span class="p">,</span> <span class="s2">&quot;Pb&quot;</span><span class="p">,</span> <span class="s2">&quot;Bi&quot;</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_rare_earth_metal</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        True if element is a rare earth metal.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_lanthanoid</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_actinoid</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_metal</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: True if is a metal.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">is_alkali</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_alkaline</span> <span class="ow">or</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">is_post_transition_metal</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_transition_metal</span> <span class="ow">or</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">is_lanthanoid</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_actinoid</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_metalloid</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        True if element is a metalloid.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;B&quot;</span><span class="p">,</span> <span class="s2">&quot;Si&quot;</span><span class="p">,</span> <span class="s2">&quot;Ge&quot;</span><span class="p">,</span> <span class="s2">&quot;As&quot;</span><span class="p">,</span> <span class="s2">&quot;Sb&quot;</span><span class="p">,</span> <span class="s2">&quot;Te&quot;</span><span class="p">,</span> <span class="s2">&quot;Po&quot;</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_alkali</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        True if element is an alkali metal.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="ow">in</span> <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="mi">11</span><span class="p">,</span> <span class="mi">19</span><span class="p">,</span> <span class="mi">37</span><span class="p">,</span> <span class="mi">55</span><span class="p">,</span> <span class="mi">87</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_alkaline</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        True if element is an alkaline earth metal (group II).</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="ow">in</span> <span class="p">(</span><span class="mi">4</span><span class="p">,</span> <span class="mi">12</span><span class="p">,</span> <span class="mi">20</span><span class="p">,</span> <span class="mi">38</span><span class="p">,</span> <span class="mi">56</span><span class="p">,</span> <span class="mi">88</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_halogen</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        True if element is a halogen.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="ow">in</span> <span class="p">(</span><span class="mi">9</span><span class="p">,</span> <span class="mi">17</span><span class="p">,</span> <span class="mi">35</span><span class="p">,</span> <span class="mi">53</span><span class="p">,</span> <span class="mi">85</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_chalcogen</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        True if element is a chalcogen.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="ow">in</span> <span class="p">(</span><span class="mi">8</span><span class="p">,</span> <span class="mi">16</span><span class="p">,</span> <span class="mi">34</span><span class="p">,</span> <span class="mi">52</span><span class="p">,</span> <span class="mi">84</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_lanthanoid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        True if element is a lanthanoid.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="mi">56</span> <span class="o">&lt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="o">&lt;</span> <span class="mi">72</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_actinoid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        True if element is a actinoid.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="mi">88</span> <span class="o">&lt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="o">&lt;</span> <span class="mi">104</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_quadrupolar</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Checks if this element can be quadrupolar</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;NMR Quadrupole Moment&quot;</span><span class="p">,</span> <span class="p">{}))</span> <span class="o">&gt;</span> <span class="mi">0</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">nmr_quadrupole_moment</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get a dictionary the nuclear electric quadrupole moment in units of</span>
<span class="sd">        e*millibarns for various isotopes</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">{</span><span class="n">k</span><span class="p">:</span> <span class="n">FloatWithUnit</span><span class="p">(</span><span class="n">v</span><span class="p">,</span> <span class="s2">&quot;mbarn&quot;</span><span class="p">)</span>
                <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;NMR Quadrupole Moment&quot;</span><span class="p">,</span> <span class="p">{})</span><span class="o">.</span><span class="n">items</span><span class="p">()}</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">iupac_ordering</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Ordering according to Table VI of &quot;Nomenclature of Inorganic Chemistry</span>
<span class="sd">        (IUPAC Recommendations 2005)&quot;. This ordering effectively follows the</span>
<span class="sd">        groups and rows of the periodic table, except the Lanthanides, Actanides</span>
<span class="sd">        and hydrogen.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_data</span><span class="p">[</span><span class="s2">&quot;IUPAC ordering&quot;</span><span class="p">]</span>

    <span class="k">def</span> <span class="nf">__deepcopy__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">memo</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">Element</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">symbol</span><span class="p">)</span>

<div class="viewcode-block" id="Element.from_dict"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Element.from_dict">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="n">d</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Makes Element obey the general json interface used in pymatgen for</span>
<span class="sd">        easier serialization.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="n">Element</span><span class="p">(</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;element&quot;</span><span class="p">])</span></div>

<div class="viewcode-block" id="Element.as_dict"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Element.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Makes Element obey the general json interface used in pymatgen for</span>
<span class="sd">        easier serialization.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">{</span><span class="s2">&quot;@module&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__module__</span><span class="p">,</span>
                <span class="s2">&quot;@class&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
                <span class="s2">&quot;element&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span><span class="p">}</span></div>

<div class="viewcode-block" id="Element.print_periodic_table"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Element.print_periodic_table">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">print_periodic_table</span><span class="p">(</span><span class="n">filter_function</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="n">Callable</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        A pretty ASCII printer for the periodic table, based on some</span>
<span class="sd">        filter_function.</span>

<span class="sd">        Args:</span>
<span class="sd">            filter_function: A filtering function taking an Element as input</span>
<span class="sd">                and returning a boolean. For example, setting</span>
<span class="sd">                filter_function = lambda el: el.X &gt; 2 will print a periodic</span>
<span class="sd">                table containing only elements with electronegativity &gt; 2.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">10</span><span class="p">):</span>
            <span class="n">rowstr</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">group</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">19</span><span class="p">):</span>
                <span class="k">try</span><span class="p">:</span>
                    <span class="n">el</span> <span class="o">=</span> <span class="n">Element</span><span class="o">.</span><span class="n">from_row_and_group</span><span class="p">(</span><span class="n">row</span><span class="p">,</span> <span class="n">group</span><span class="p">)</span>
                <span class="k">except</span> <span class="ne">ValueError</span><span class="p">:</span>
                    <span class="n">el</span> <span class="o">=</span> <span class="kc">None</span>
                <span class="k">if</span> <span class="n">el</span> <span class="ow">and</span> <span class="p">((</span><span class="ow">not</span> <span class="n">filter_function</span><span class="p">)</span> <span class="ow">or</span> <span class="n">filter_function</span><span class="p">(</span><span class="n">el</span><span class="p">)):</span>
                    <span class="n">rowstr</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{:3s}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">el</span><span class="o">.</span><span class="n">symbol</span><span class="p">))</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">rowstr</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot;   &quot;</span><span class="p">)</span>
            <span class="nb">print</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">rowstr</span><span class="p">))</span></div></div>


<div class="viewcode-block" id="Specie"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Specie">[docs]</a><span class="k">class</span> <span class="nc">Specie</span><span class="p">(</span><span class="n">MSONable</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    An extension of Element with an oxidation state and other optional</span>
<span class="sd">    properties. Properties associated with Specie should be &quot;idealized&quot;</span>
<span class="sd">    values, not calculated values. For example, high-spin Fe2+ may be</span>
<span class="sd">    assigned an idealized spin of +5, but an actual Fe2+ site may be</span>
<span class="sd">    calculated to have a magmom of +4.5. Calculated properties should be</span>
<span class="sd">    assigned to Site objects, and not Specie.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="n">supported_properties</span> <span class="o">=</span> <span class="p">(</span><span class="s2">&quot;spin&quot;</span><span class="p">,)</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">symbol</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span>
                 <span class="n">oxidation_state</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.0</span><span class="p">,</span>
                 <span class="n">properties</span><span class="p">:</span> <span class="nb">dict</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Initializes a Specie.</span>

<span class="sd">        Args:</span>
<span class="sd">            symbol (str): Element symbol, e.g., Fe</span>
<span class="sd">            oxidation_state (float): Oxidation state of element, e.g., 2 or -2</span>
<span class="sd">            properties: Properties associated with the Specie, e.g.,</span>
<span class="sd">                {&quot;spin&quot;: 5}. Defaults to None. Properties must be one of the</span>
<span class="sd">                Specie supported_properties.</span>

<span class="sd">        .. attribute:: oxi_state</span>

<span class="sd">            Oxidation state associated with Specie</span>

<span class="sd">        .. attribute:: ionic_radius</span>

<span class="sd">            Ionic radius of Specie (with specific oxidation state).</span>

<span class="sd">        .. versionchanged:: 2.6.7</span>

<span class="sd">            Properties are now checked when comparing two Species for equality.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_el</span> <span class="o">=</span> <span class="n">Element</span><span class="p">(</span><span class="n">symbol</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_oxi_state</span> <span class="o">=</span> <span class="n">oxidation_state</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_properties</span> <span class="o">=</span> <span class="n">properties</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_properties</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">k</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">Specie</span><span class="o">.</span><span class="n">supported_properties</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> is not a supported property&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">k</span><span class="p">))</span>

    <span class="k">def</span> <span class="fm">__getattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">a</span><span class="p">):</span>
        <span class="c1"># overriding getattr doesn&#39;t play nice with pickle, so we</span>
        <span class="c1"># can&#39;t use self._properties</span>
        <span class="n">p</span> <span class="o">=</span> <span class="nb">object</span><span class="o">.</span><span class="fm">__getattribute__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">&#39;_properties&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">p</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">p</span><span class="p">[</span><span class="n">a</span><span class="p">]</span>
        <span class="k">return</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_el</span><span class="p">,</span> <span class="n">a</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Specie is equal to other only if element and oxidation states are</span>
<span class="sd">        exactly the same.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="n">Specie</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">symbol</span>
                <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">oxi_state</span>
                <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_properties</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">_properties</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__ne__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="k">return</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__eq__</span><span class="p">(</span><span class="n">other</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Equal Specie should have the same str representation, hence</span>
<span class="sd">        should hash equally. Unequal Specie will have differnt str</span>
<span class="sd">        representations.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__str__</span><span class="p">()</span><span class="o">.</span><span class="fm">__hash__</span><span class="p">()</span>

    <span class="k">def</span> <span class="fm">__lt__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Sets a default sort order for atomic species by electronegativity,</span>
<span class="sd">        followed by oxidation state, followed by spin.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">x1</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="s2">&quot;inf&quot;</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span>
        <span class="n">x2</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="s2">&quot;inf&quot;</span><span class="p">)</span> <span class="k">if</span> <span class="n">other</span><span class="o">.</span><span class="n">X</span> <span class="o">!=</span> <span class="n">other</span><span class="o">.</span><span class="n">X</span> <span class="k">else</span> <span class="n">other</span><span class="o">.</span><span class="n">X</span>
        <span class="k">if</span> <span class="n">x1</span> <span class="o">!=</span> <span class="n">x2</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">x1</span> <span class="o">&lt;</span> <span class="n">x2</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span> <span class="o">!=</span> <span class="n">other</span><span class="o">.</span><span class="n">symbol</span><span class="p">:</span>
            <span class="c1"># There are cases where the electronegativity are exactly equal.</span>
            <span class="c1"># We then sort by symbol.</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span> <span class="o">&lt;</span> <span class="n">other</span><span class="o">.</span><span class="n">symbol</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span><span class="p">:</span>
            <span class="n">other_oxi</span> <span class="o">=</span> <span class="mi">0</span> <span class="k">if</span> <span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="n">Element</span><span class="p">)</span>
                              <span class="ow">or</span> <span class="n">other</span><span class="o">.</span><span class="n">oxi_state</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">)</span> <span class="k">else</span> <span class="n">other</span><span class="o">.</span><span class="n">oxi_state</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span> <span class="o">&lt;</span> <span class="n">other_oxi</span>
        <span class="k">if</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s2">&quot;spin&quot;</span><span class="p">,</span> <span class="kc">False</span><span class="p">):</span>
            <span class="n">other_spin</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="s2">&quot;spin&quot;</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">spin</span> <span class="o">&lt;</span> <span class="n">other_spin</span>
        <span class="k">return</span> <span class="kc">False</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">element</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Underlying element object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_el</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">ionic_radius</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Ionic radius of specie. Returns None if data is not present.</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_oxi_state</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">ionic_radii</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">ionic_radii</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_oxi_state</span><span class="p">]</span>
        <span class="n">d</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_el</span><span class="o">.</span><span class="n">data</span>
        <span class="n">oxstr</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_oxi_state</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">oxstr</span> <span class="ow">in</span> <span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;Ionic radii hs&quot;</span><span class="p">,</span> <span class="p">{}):</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;No default ionic radius for </span><span class="si">%s</span><span class="s2">. Using hs data.&quot;</span> <span class="o">%</span>
                          <span class="bp">self</span><span class="p">)</span>
            <span class="k">return</span> <span class="n">d</span><span class="p">[</span><span class="s2">&quot;Ionic radii hs&quot;</span><span class="p">][</span><span class="n">oxstr</span><span class="p">]</span>
        <span class="k">if</span> <span class="n">oxstr</span> <span class="ow">in</span> <span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;Ionic radii ls&quot;</span><span class="p">,</span> <span class="p">{}):</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;No default ionic radius for </span><span class="si">%s</span><span class="s2">. Using ls data.&quot;</span> <span class="o">%</span>
                          <span class="bp">self</span><span class="p">)</span>
            <span class="k">return</span> <span class="n">d</span><span class="p">[</span><span class="s2">&quot;Ionic radii ls&quot;</span><span class="p">][</span><span class="n">oxstr</span><span class="p">]</span>
        <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;No ionic radius for </span><span class="si">{}</span><span class="s2">!&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="p">))</span>
        <span class="k">return</span> <span class="kc">None</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">oxi_state</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Oxidation state of Specie.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_oxi_state</span>

<div class="viewcode-block" id="Specie.from_string"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Specie.from_string">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">from_string</span><span class="p">(</span><span class="n">species_string</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns a Specie from a string representation.</span>

<span class="sd">        Args:</span>
<span class="sd">            species_string (str): A typical string representation of a</span>
<span class="sd">                species, e.g., &quot;Mn2+&quot;, &quot;Fe3+&quot;, &quot;O2-&quot;.</span>

<span class="sd">        Returns:</span>
<span class="sd">            A Specie object.</span>

<span class="sd">        Raises:</span>
<span class="sd">            ValueError if species_string cannot be intepreted.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">m</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;([A-Z][a-z]*)([0-9.]*)([+\-])(.*)&quot;</span><span class="p">,</span> <span class="n">species_string</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
            <span class="n">sym</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
            <span class="n">oxi</span> <span class="o">=</span> <span class="mi">1</span> <span class="k">if</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span> <span class="k">else</span> <span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
            <span class="n">oxi</span> <span class="o">=</span> <span class="o">-</span><span class="n">oxi</span> <span class="k">if</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="o">==</span> <span class="s2">&quot;-&quot;</span> <span class="k">else</span> <span class="n">oxi</span>
            <span class="n">properties</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">if</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">4</span><span class="p">):</span>
                <span class="n">toks</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;,&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;=&quot;</span><span class="p">)</span>
                <span class="n">properties</span> <span class="o">=</span> <span class="p">{</span><span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span> <span class="nb">float</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">])}</span>
            <span class="k">return</span> <span class="n">Specie</span><span class="p">(</span><span class="n">sym</span><span class="p">,</span> <span class="n">oxi</span><span class="p">,</span> <span class="n">properties</span><span class="p">)</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Invalid Species String&quot;</span><span class="p">)</span></div>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s2">&quot;Specie &quot;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__str__</span><span class="p">()</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">output</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">output</span> <span class="o">+=</span> <span class="n">formula_double_format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;+&quot;</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">output</span> <span class="o">+=</span> <span class="n">formula_double_format</span><span class="p">(</span><span class="o">-</span><span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;-&quot;</span>
        <span class="k">for</span> <span class="n">p</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_properties</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="n">output</span> <span class="o">+=</span> <span class="s2">&quot;,</span><span class="si">%s</span><span class="s2">=</span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">output</span>

<div class="viewcode-block" id="Specie.get_nmr_quadrupole_moment"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Specie.get_nmr_quadrupole_moment">[docs]</a>    <span class="k">def</span> <span class="nf">get_nmr_quadrupole_moment</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">isotope</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Gets the nuclear electric quadrupole moment in units of</span>
<span class="sd">        e*millibarns</span>

<span class="sd">        Args:</span>
<span class="sd">            isotope (str): the isotope to get the quadrupole moment for</span>
<span class="sd">                default is None, which gets the lowest mass isotope</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">quad_mom</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_el</span><span class="o">.</span><span class="n">nmr_quadrupole_moment</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="n">quad_mom</span><span class="p">:</span>
            <span class="k">return</span> <span class="mf">0.0</span>

        <span class="k">if</span> <span class="n">isotope</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">isotopes</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">quad_mom</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
            <span class="n">isotopes</span><span class="o">.</span><span class="n">sort</span><span class="p">(</span><span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="nb">int</span><span class="p">(</span><span class="n">x</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;-&quot;</span><span class="p">)[</span><span class="mi">1</span><span class="p">]),</span> <span class="n">reverse</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
            <span class="k">return</span> <span class="n">quad_mom</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">isotopes</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="mf">0.0</span><span class="p">)</span>

        <span class="k">if</span> <span class="n">isotope</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">quad_mom</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;No quadrupole moment for isotope </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span>
                <span class="n">isotope</span><span class="p">))</span>
        <span class="k">return</span> <span class="n">quad_mom</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">isotope</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span></div>

<div class="viewcode-block" id="Specie.get_shannon_radius"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Specie.get_shannon_radius">[docs]</a>    <span class="k">def</span> <span class="nf">get_shannon_radius</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">cn</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">spin</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;&quot;</span><span class="p">,</span>
                           <span class="n">radius_type</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;ionic&quot;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Get the local environment specific ionic radius for species.</span>

<span class="sd">        Args:</span>
<span class="sd">            cn (str): Coordination using roman letters. Supported values are</span>
<span class="sd">                I-IX, as well as IIIPY, IVPY and IVSQ.</span>
<span class="sd">            spin (str): Some species have different radii for different</span>
<span class="sd">                spins. You can get specific values using &quot;High Spin&quot; or</span>
<span class="sd">                &quot;Low Spin&quot;. Leave it as &quot;&quot; if not available. If only one spin</span>
<span class="sd">                data is available, it is returned and this spin parameter is</span>
<span class="sd">                ignored.</span>
<span class="sd">            radius_type (str): Either &quot;crystal&quot; or &quot;ionic&quot; (default).</span>

<span class="sd">        Returns:</span>
<span class="sd">            Shannon radius for specie in the specified environment.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">radii</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_el</span><span class="o">.</span><span class="n">data</span><span class="p">[</span><span class="s2">&quot;Shannon radii&quot;</span><span class="p">]</span>
        <span class="n">radii</span> <span class="o">=</span> <span class="n">radii</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_oxi_state</span><span class="p">))][</span><span class="n">cn</span><span class="p">]</span>  <span class="c1"># type: ignore</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">radii</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>  <span class="c1"># type: ignore</span>
            <span class="n">k</span><span class="p">,</span> <span class="n">data</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">radii</span><span class="o">.</span><span class="n">items</span><span class="p">())[</span><span class="mi">0</span><span class="p">]</span>  <span class="c1"># type: ignore</span>
            <span class="k">if</span> <span class="n">k</span> <span class="o">!=</span> <span class="n">spin</span><span class="p">:</span>
                <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span>
                    <span class="s2">&quot;Specified spin state of </span><span class="si">%s</span><span class="s2"> not consistent with database &quot;</span>
                    <span class="s2">&quot;spin of </span><span class="si">%s</span><span class="s2">. Only one spin data available, and &quot;</span>
                    <span class="s2">&quot;that value is returned.&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">spin</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
                <span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">radii</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span>
        <span class="k">return</span> <span class="n">data</span><span class="p">[</span><span class="s2">&quot;</span><span class="si">%s</span><span class="s2">_radius&quot;</span> <span class="o">%</span> <span class="n">radius_type</span><span class="p">]</span></div>

<div class="viewcode-block" id="Specie.get_crystal_field_spin"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Specie.get_crystal_field_spin">[docs]</a>    <span class="k">def</span> <span class="nf">get_crystal_field_spin</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">coordination</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;oct&quot;</span><span class="p">,</span>
                               <span class="n">spin_config</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;high&quot;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Calculate the crystal field spin based on coordination and spin</span>
<span class="sd">        configuration. Only works for transition metal species.</span>

<span class="sd">        Args:</span>
<span class="sd">            coordination (str): Only oct and tet are supported at the moment.</span>
<span class="sd">            spin_config (str): Supported keywords are &quot;high&quot; or &quot;low&quot;.</span>

<span class="sd">        Returns:</span>
<span class="sd">            Crystal field spin in Bohr magneton.</span>

<span class="sd">        Raises:</span>
<span class="sd">            AttributeError if species is not a valid transition metal or has</span>
<span class="sd">            an invalid oxidation state.</span>
<span class="sd">            ValueError if invalid coordination or spin_config.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">coordination</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;oct&quot;</span><span class="p">,</span> <span class="s2">&quot;tet&quot;</span><span class="p">)</span> <span class="ow">or</span> <span class="n">spin_config</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="s2">&quot;high&quot;</span><span class="p">,</span> <span class="s2">&quot;low&quot;</span><span class="p">):</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Invalid coordination or spin config.&quot;</span><span class="p">)</span>
        <span class="n">elec</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">full_electronic_structure</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">elec</span><span class="p">)</span> <span class="o">&lt;</span> <span class="mi">4</span> <span class="ow">or</span> <span class="n">elec</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="s2">&quot;s&quot;</span> <span class="ow">or</span> <span class="n">elec</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">!=</span> <span class="s2">&quot;d&quot;</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">AttributeError</span><span class="p">(</span>
                <span class="s2">&quot;Invalid element </span><span class="si">{}</span><span class="s2"> for crystal field calculation.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">symbol</span><span class="p">))</span>
        <span class="n">nelectrons</span> <span class="o">=</span> <span class="n">elec</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="n">elec</span><span class="p">[</span><span class="o">-</span><span class="mi">2</span><span class="p">][</span><span class="mi">2</span><span class="p">]</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span>
        <span class="k">if</span> <span class="n">nelectrons</span> <span class="o">&lt;</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">nelectrons</span> <span class="o">&gt;</span> <span class="mi">10</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">AttributeError</span><span class="p">(</span>
                <span class="s2">&quot;Invalid oxidation state </span><span class="si">{}</span><span class="s2"> for element </span><span class="si">{}</span><span class="s2">&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span><span class="p">))</span>
        <span class="k">if</span> <span class="n">spin_config</span> <span class="o">==</span> <span class="s2">&quot;high&quot;</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">nelectrons</span> <span class="o">&lt;=</span> <span class="mi">5</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">nelectrons</span>
            <span class="k">return</span> <span class="mi">10</span> <span class="o">-</span> <span class="n">nelectrons</span>
        <span class="k">if</span> <span class="n">spin_config</span> <span class="o">==</span> <span class="s2">&quot;low&quot;</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">coordination</span> <span class="o">==</span> <span class="s2">&quot;oct&quot;</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">nelectrons</span> <span class="o">&lt;=</span> <span class="mi">3</span><span class="p">:</span>
                    <span class="k">return</span> <span class="n">nelectrons</span>
                <span class="k">if</span> <span class="n">nelectrons</span> <span class="o">&lt;=</span> <span class="mi">6</span><span class="p">:</span>
                    <span class="k">return</span> <span class="mi">6</span> <span class="o">-</span> <span class="n">nelectrons</span>
                <span class="k">if</span> <span class="n">nelectrons</span> <span class="o">&lt;=</span> <span class="mi">8</span><span class="p">:</span>
                    <span class="k">return</span> <span class="n">nelectrons</span> <span class="o">-</span> <span class="mi">6</span>
                <span class="k">return</span> <span class="mi">10</span> <span class="o">-</span> <span class="n">nelectrons</span>
            <span class="k">if</span> <span class="n">coordination</span> <span class="o">==</span> <span class="s2">&quot;tet&quot;</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">nelectrons</span> <span class="o">&lt;=</span> <span class="mi">2</span><span class="p">:</span>
                    <span class="k">return</span> <span class="n">nelectrons</span>
                <span class="k">if</span> <span class="n">nelectrons</span> <span class="o">&lt;=</span> <span class="mi">4</span><span class="p">:</span>
                    <span class="k">return</span> <span class="mi">4</span> <span class="o">-</span> <span class="n">nelectrons</span>
                <span class="k">if</span> <span class="n">nelectrons</span> <span class="o">&lt;=</span> <span class="mi">7</span><span class="p">:</span>
                    <span class="k">return</span> <span class="n">nelectrons</span> <span class="o">-</span> <span class="mi">4</span>
                <span class="k">return</span> <span class="mi">10</span> <span class="o">-</span> <span class="n">nelectrons</span>
        <span class="k">raise</span> <span class="ne">RuntimeError</span><span class="p">()</span></div>

    <span class="k">def</span> <span class="nf">__deepcopy__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">memo</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">Specie</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">symbol</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_properties</span><span class="p">)</span>

<div class="viewcode-block" id="Specie.as_dict"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Specie.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Json-able dictionary representation.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">d</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;@module&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__module__</span><span class="p">,</span>
             <span class="s2">&quot;@class&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
             <span class="s2">&quot;element&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span><span class="p">,</span>
             <span class="s2">&quot;oxidation_state&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_oxi_state</span><span class="p">}</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_properties</span><span class="p">:</span>
            <span class="n">d</span><span class="p">[</span><span class="s2">&quot;properties&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_properties</span>
        <span class="k">return</span> <span class="n">d</span></div>

<div class="viewcode-block" id="Specie.from_dict"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.Specie.from_dict">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :param d: Dict representation.</span>
<span class="sd">        :return: Specie.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;element&quot;</span><span class="p">],</span> <span class="n">d</span><span class="p">[</span><span class="s2">&quot;oxidation_state&quot;</span><span class="p">],</span>
                   <span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;properties&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span></div></div>


<div class="viewcode-block" id="DummySpecie"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.DummySpecie">[docs]</a><span class="k">class</span> <span class="nc">DummySpecie</span><span class="p">(</span><span class="n">Specie</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    A special specie for representing non-traditional elements or species. For</span>
<span class="sd">    example, representation of vacancies (charged or otherwise), or special</span>
<span class="sd">    sites, etc.</span>

<span class="sd">    .. attribute:: oxi_state</span>

<span class="sd">        Oxidation state associated with Specie.</span>

<span class="sd">    .. attribute:: Z</span>

<span class="sd">        DummySpecie is always assigned an atomic number equal to the hash</span>
<span class="sd">        number of the symbol. Obviously, it makes no sense whatsoever to use</span>
<span class="sd">        the atomic number of a Dummy specie for anything scientific. The purpose</span>
<span class="sd">        of this is to ensure that for most use cases, a DummySpecie behaves no</span>
<span class="sd">        differently from an Element or Specie.</span>

<span class="sd">    .. attribute:: X</span>

<span class="sd">        DummySpecie is always assigned an electronegativity of 0.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span>
                 <span class="n">symbol</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;X&quot;</span><span class="p">,</span>
                 <span class="n">oxidation_state</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span>
                 <span class="n">properties</span><span class="p">:</span> <span class="nb">dict</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            symbol (str): An assigned symbol for the dummy specie. Strict</span>
<span class="sd">                rules are applied to the choice of the symbol. The dummy</span>
<span class="sd">                symbol cannot have any part of first two letters that will</span>
<span class="sd">                constitute an Element symbol. Otherwise, a composition may</span>
<span class="sd">                be parsed wrongly. E.g., &quot;X&quot; is fine, but &quot;Vac&quot; is not</span>
<span class="sd">                because Vac contains V, a valid Element.</span>
<span class="sd">            oxidation_state (float): Oxidation state for dummy specie.</span>
<span class="sd">                Defaults to zero.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># enforce title case to match other elements, reduces confusion</span>
        <span class="c1"># when multiple DummySpecie in a &quot;formula&quot; string</span>
        <span class="n">symbol</span> <span class="o">=</span> <span class="n">symbol</span><span class="o">.</span><span class="n">title</span><span class="p">()</span>

        <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nb">min</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">symbol</span><span class="p">))</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">Element</span><span class="o">.</span><span class="n">is_valid_symbol</span><span class="p">(</span><span class="n">symbol</span><span class="p">[:</span><span class="n">i</span><span class="p">]):</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> contains </span><span class="si">{}</span><span class="s2">, which is a valid element &quot;</span>
                                 <span class="s2">&quot;symbol.&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">symbol</span><span class="p">,</span> <span class="n">symbol</span><span class="p">[:</span><span class="n">i</span><span class="p">]))</span>

        <span class="c1"># Set required attributes for DummySpecie to function like a Specie in</span>
        <span class="c1"># most instances.</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_symbol</span> <span class="o">=</span> <span class="n">symbol</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_oxi_state</span> <span class="o">=</span> <span class="n">oxidation_state</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_properties</span> <span class="o">=</span> <span class="n">properties</span> <span class="k">if</span> <span class="n">properties</span> <span class="k">else</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_properties</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
            <span class="k">if</span> <span class="n">k</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">Specie</span><span class="o">.</span><span class="n">supported_properties</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;</span><span class="si">{}</span><span class="s2"> is not a supported property&quot;</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">k</span><span class="p">))</span>

    <span class="k">def</span> <span class="fm">__getattr__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">a</span><span class="p">):</span>
        <span class="c1"># overriding getattr doens&#39;t play nice with pickle, so we</span>
        <span class="c1"># can&#39;t use self._properties</span>
        <span class="n">p</span> <span class="o">=</span> <span class="nb">object</span><span class="o">.</span><span class="fm">__getattribute__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s1">&#39;_properties&#39;</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">a</span> <span class="ow">in</span> <span class="n">p</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">p</span><span class="p">[</span><span class="n">a</span><span class="p">]</span>
        <span class="k">raise</span> <span class="ne">AttributeError</span><span class="p">(</span><span class="n">a</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__hash__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span><span class="o">.</span><span class="fm">__hash__</span><span class="p">()</span>

    <span class="k">def</span> <span class="fm">__eq__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Specie is equal to other only if element and oxidation states are</span>
<span class="sd">        exactly the same.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="n">DummySpecie</span><span class="p">):</span>
            <span class="k">return</span> <span class="kc">False</span>
        <span class="k">return</span> <span class="p">(</span><span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="n">Specie</span><span class="p">)</span> <span class="ow">and</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">symbol</span> <span class="ow">and</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">oxi_state</span> <span class="ow">and</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">_properties</span> <span class="o">==</span> <span class="n">other</span><span class="o">.</span><span class="n">_properties</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__ne__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="k">return</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__eq__</span><span class="p">(</span><span class="n">other</span><span class="p">)</span>

    <span class="k">def</span> <span class="fm">__lt__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">other</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Sets a default sort order for atomic species by electronegativity,</span>
<span class="sd">        followed by oxidation state.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span> <span class="o">!=</span> <span class="n">other</span><span class="o">.</span><span class="n">X</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">X</span> <span class="o">&lt;</span> <span class="n">other</span><span class="o">.</span><span class="n">X</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span> <span class="o">!=</span> <span class="n">other</span><span class="o">.</span><span class="n">symbol</span><span class="p">:</span>
            <span class="c1"># There are cases where the electronegativity are exactly equal.</span>
            <span class="c1"># We then sort by symbol.</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span> <span class="o">&lt;</span> <span class="n">other</span><span class="o">.</span><span class="n">symbol</span>
        <span class="n">other_oxi</span> <span class="o">=</span> <span class="mi">0</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">other</span><span class="p">,</span> <span class="n">Element</span><span class="p">)</span> <span class="k">else</span> <span class="n">other</span><span class="o">.</span><span class="n">oxi_state</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span> <span class="o">&lt;</span> <span class="n">other_oxi</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">Z</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">int</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        DummySpecie is always assigned an atomic number equal to the hash of</span>
<span class="sd">        the symbol. The expectation is that someone would be an actual dummy</span>
<span class="sd">        to use atomic numbers for a Dummy specie.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span><span class="o">.</span><span class="fm">__hash__</span><span class="p">()</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">oxi_state</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">float</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Oxidation state associated with DummySpecie</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_oxi_state</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">X</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">float</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        DummySpecie is always assigned an electronegativity of 0. The effect of</span>
<span class="sd">        this is that DummySpecie are always sorted in front of actual Specie.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="mf">0.0</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">symbol</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">str</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Symbol for DummySpecie.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_symbol</span>

    <span class="k">def</span> <span class="nf">__deepcopy__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">memo</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">DummySpecie</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">symbol</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_oxi_state</span><span class="p">)</span>

<div class="viewcode-block" id="DummySpecie.from_string"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.DummySpecie.from_string">[docs]</a>    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">from_string</span><span class="p">(</span><span class="n">species_string</span><span class="p">:</span> <span class="nb">str</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns a Dummy from a string representation.</span>

<span class="sd">        Args:</span>
<span class="sd">            species_string (str): A string representation of a dummy</span>
<span class="sd">                species, e.g., &quot;X2+&quot;, &quot;X3+&quot;.</span>

<span class="sd">        Returns:</span>
<span class="sd">            A DummySpecie object.</span>

<span class="sd">        Raises:</span>
<span class="sd">            ValueError if species_string cannot be intepreted.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">m</span> <span class="o">=</span> <span class="n">re</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;([A-ZAa-z]*)([0-9.]*)([+\-]*)(.*)&quot;</span><span class="p">,</span> <span class="n">species_string</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">m</span><span class="p">:</span>
            <span class="n">sym</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
            <span class="k">if</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span> <span class="ow">and</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span><span class="p">:</span>
                <span class="n">oxi</span> <span class="o">=</span> <span class="mf">0.0</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">oxi</span> <span class="o">=</span> <span class="mf">1.0</span> <span class="k">if</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span> <span class="o">==</span> <span class="s2">&quot;&quot;</span> <span class="k">else</span> <span class="nb">float</span><span class="p">(</span><span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">2</span><span class="p">))</span>
                <span class="n">oxi</span> <span class="o">=</span> <span class="o">-</span><span class="n">oxi</span> <span class="k">if</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">3</span><span class="p">)</span> <span class="o">==</span> <span class="s2">&quot;-&quot;</span> <span class="k">else</span> <span class="n">oxi</span>
            <span class="n">properties</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="k">if</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">4</span><span class="p">):</span>
                <span class="n">toks</span> <span class="o">=</span> <span class="n">m</span><span class="o">.</span><span class="n">group</span><span class="p">(</span><span class="mi">4</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;=&quot;</span><span class="p">)</span>
                <span class="n">properties</span> <span class="o">=</span> <span class="p">{</span><span class="n">toks</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span> <span class="nb">float</span><span class="p">(</span><span class="n">toks</span><span class="p">[</span><span class="mi">1</span><span class="p">])}</span>
            <span class="k">return</span> <span class="n">DummySpecie</span><span class="p">(</span><span class="n">sym</span><span class="p">,</span> <span class="n">oxi</span><span class="p">,</span> <span class="n">properties</span><span class="p">)</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Invalid DummySpecies String&quot;</span><span class="p">)</span></div>

<div class="viewcode-block" id="DummySpecie.as_dict"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.DummySpecie.as_dict">[docs]</a>    <span class="k">def</span> <span class="nf">as_dict</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: MSONAble dict representation.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">d</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;@module&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__module__</span><span class="p">,</span>
             <span class="s2">&quot;@class&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
             <span class="s2">&quot;element&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span><span class="p">,</span>
             <span class="s2">&quot;oxidation_state&quot;</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">_oxi_state</span><span class="p">}</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_properties</span><span class="p">:</span>
            <span class="n">d</span><span class="p">[</span><span class="s2">&quot;properties&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_properties</span>
        <span class="k">return</span> <span class="n">d</span></div>

<div class="viewcode-block" id="DummySpecie.from_dict"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.DummySpecie.from_dict">[docs]</a>    <span class="nd">@classmethod</span>
    <span class="k">def</span> <span class="nf">from_dict</span><span class="p">(</span><span class="bp">cls</span><span class="p">,</span> <span class="n">d</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :param d: Dict representation</span>
<span class="sd">        :return: DummySpecie</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">cls</span><span class="p">(</span><span class="n">d</span><span class="p">[</span><span class="s2">&quot;element&quot;</span><span class="p">],</span> <span class="n">d</span><span class="p">[</span><span class="s2">&quot;oxidation_state&quot;</span><span class="p">],</span>
                   <span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">&quot;properties&quot;</span><span class="p">,</span> <span class="kc">None</span><span class="p">))</span></div>

    <span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s2">&quot;DummySpecie &quot;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="fm">__str__</span><span class="p">()</span>

    <span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">output</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">symbol</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
            <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span> <span class="o">&gt;=</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">output</span> <span class="o">+=</span> <span class="n">formula_double_format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;+&quot;</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">output</span> <span class="o">+=</span> <span class="n">formula_double_format</span><span class="p">(</span><span class="o">-</span><span class="bp">self</span><span class="o">.</span><span class="n">oxi_state</span><span class="p">)</span> <span class="o">+</span> <span class="s2">&quot;-&quot;</span>
        <span class="k">for</span> <span class="n">p</span><span class="p">,</span> <span class="n">v</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_properties</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="n">output</span> <span class="o">+=</span> <span class="s2">&quot;,</span><span class="si">%s</span><span class="s2">=</span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">p</span><span class="p">,</span> <span class="n">v</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">output</span></div>


<div class="viewcode-block" id="get_el_sp"><a class="viewcode-back" href="../../../pymatgen.core.periodic_table.html#pymatgen.core.periodic_table.get_el_sp">[docs]</a><span class="k">def</span> <span class="nf">get_el_sp</span><span class="p">(</span><span class="n">obj</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Utility method to get an Element or Specie from an input obj.</span>
<span class="sd">    If obj is in itself an element or a specie, it is returned automatically.</span>
<span class="sd">    If obj is an int or a string representing an integer, the Element</span>
<span class="sd">    with the atomic number obj is returned.</span>
<span class="sd">    If obj is a string, Specie parsing will be attempted (e.g., Mn2+), failing</span>
<span class="sd">    which Element parsing will be attempted (e.g., Mn), failing which</span>
<span class="sd">    DummyElement parsing will be attempted.</span>

<span class="sd">    Args:</span>
<span class="sd">        obj (Element/Specie/str/int): An arbitrary object.  Supported objects</span>
<span class="sd">            are actual Element/Specie objects, integers (representing atomic</span>
<span class="sd">            numbers) or strings (element symbols or species strings).</span>

<span class="sd">    Returns:</span>
<span class="sd">        Specie or Element, with a bias for the maximum number of properties</span>
<span class="sd">        that can be determined.</span>

<span class="sd">    Raises:</span>
<span class="sd">        ValueError if obj cannot be converted into an Element or Specie.</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="p">(</span><span class="n">Element</span><span class="p">,</span> <span class="n">Specie</span><span class="p">,</span> <span class="n">DummySpecie</span><span class="p">)):</span>
        <span class="k">return</span> <span class="n">obj</span>

    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">obj</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)):</span>
        <span class="k">return</span> <span class="p">[</span><span class="n">get_el_sp</span><span class="p">(</span><span class="n">o</span><span class="p">)</span> <span class="k">for</span> <span class="n">o</span> <span class="ow">in</span> <span class="n">obj</span><span class="p">]</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="n">c</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span>
        <span class="n">i</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>
        <span class="n">i</span> <span class="o">=</span> <span class="n">i</span> <span class="k">if</span> <span class="n">i</span> <span class="o">==</span> <span class="n">c</span> <span class="k">else</span> <span class="kc">None</span>
    <span class="k">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">TypeError</span><span class="p">):</span>
        <span class="n">i</span> <span class="o">=</span> <span class="kc">None</span>

    <span class="k">if</span> <span class="n">i</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
        <span class="k">return</span> <span class="n">Element</span><span class="o">.</span><span class="n">from_Z</span><span class="p">(</span><span class="n">i</span><span class="p">)</span>

    <span class="k">try</span><span class="p">:</span>
        <span class="k">return</span> <span class="n">Specie</span><span class="o">.</span><span class="n">from_string</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span>
    <span class="k">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">KeyError</span><span class="p">):</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="k">return</span> <span class="n">Element</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span>
        <span class="k">except</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">,</span> <span class="ne">KeyError</span><span class="p">):</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="k">return</span> <span class="n">DummySpecie</span><span class="o">.</span><span class="n">from_string</span><span class="p">(</span><span class="n">obj</span><span class="p">)</span>
            <span class="k">except</span> <span class="ne">Exception</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;Can&#39;t parse Element or String from type&quot;</span>
                                 <span class="s2">&quot; </span><span class="si">%s</span><span class="s2">: </span><span class="si">%s</span><span class="s2">.&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="nb">type</span><span class="p">(</span><span class="n">obj</span><span class="p">),</span> <span class="n">obj</span><span class="p">))</span></div>
</pre></div>

            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../pymatgen.html" >pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.core.periodic_table</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>